# coding=utf-8
# 开发时间：2023/12/27 10:25

class BaseSerializer(object):
    #把python对象转换成字典
    def __init__(self,data):
        self.data=data

    def to_dict(self):
        #个性化的函数，需要子类重写
        return {}

class BaseListSerializer(object):
    """对象组序列化基类"""

    def __init__(self, data):
        self.data_list = data
        # self.select_type_serializer()

    def select_type_serializer(self):
        if not self.data_list:
            return None
        if isinstance(self.data_list, list):  # 列表解析
            if len(self.data_list) == 0:
                return None
            else:
                self.data_list = [dict(zip(result.keys(), result)) for result in self.data_list]

    def to_dict(self):
        """个性化的系列化,子类重写 """
        return {}